package com.project.api.sale.controller;

import com.project.api.common.Http;
import com.project.api.sale.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TestController {
    public static final String PATH_ROOT = "/sale";
    @Autowired
    @Qualifier("mainJdbcTemplate")
    private JdbcTemplate mainJdbcTemplate;

//    @Autowired
//    @Qualifier("saleJdbcTemplate")
//    private JdbcTemplate saleJdbcTemplate;

    @Resource
    private TestService testService;

//    @RequestMapping(PATH_ROOT)
//    public List welcome() {
//        String result= Http.Get("http://www.baidu.com","");
//        testService.say();
//        String listSql = "select * from boom";
//        List<Map> objList = saleJdbcTemplate.query(listSql, new Object[]{}, new RowMapper<Map>() {
//            @Override
//            public Map mapRow(ResultSet resultSet, int i) throws SQLException {
//                Map row = new HashMap();
//                row.put("name", resultSet.getString("name"));
//                return row;
//            }
//        });
//        String sql = "select * from milk_data";
//        List<Map> tmrlist = mainJdbcTemplate.query(sql, new Object[]{}, new RowMapper<Map>() {
//            @Override
//            public Map mapRow(ResultSet resultSet, int i) throws SQLException {
//                Map row = new HashMap();
//                row.put("milking_id", resultSet.getString("milking_id"));
//                return row;
//            }
//        });
//        List<Map> aa=objList;
//        List<Map> list=tmrlist;
//        return list;
//    }
    @RequestMapping("/fuck")
    public String my(){
        return "ffffff";
    }
}
